<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>删除用户</title>
	</head>
	<body>
		<div id="app">
			<table>
				<tbody>					
					<tr>
						<td></td>
						<td>
							<label>是否删除?</label>
							<button @click="deleteowner()" >删除</button>
							<a href="OwnerQuery.html">
								<button>返回</button>
							</a>
						</td>
						<td></td>
					</tr>
					<tr>
						<td></td>
						<td>
							<span v-if="isDeleteShow" style="color: green;">删除成功</span>
							<span v-else ></span>
						</td>						
						<td></td>												
					</tr>
				</tbody>
			</table>
		</div>
		<script src="js/vue.js"></script>
		<script src="js/axios.js"></script>
		<script src="js/urlparse.js"></script>
		<script>
			var vue = new Vue({
				el: "#app",
				data: {
					ownerID: "",
					isDeleteShow: false,
				},
				methods:{
					deleteowner: function() {
						axios({
							headers: {'content-type': 'application/x-www-form-urlencoded'},
							method: "post",
							url: "http://localhost:8888/simpleweb/owner/delete",
							data : "owner_id=" + this.ownerID,
						}).then((res) => {
							console.log(res);
							if(res.data.res) {
								
							} else {
								this.isDeleteShow = true;
							}														
						}).catch((error )=> {
							console.log(error);
						});						
					}
				},				
				mounted : function() {
					// 页面初始完成自动调用
					
					// 获得前一个页面传递的参数
					// 通过参数名字获得 参数的值
					var id = getQueryString("owner_id");
					console.log(id);
					this.ownerID = id;
					axios({
						headers: {'content-type': 'application/x-www-form-urlencoded'},
						method: "post",
						url: "http://localhost:8888/simpleweb/owner/querybyid",
						data : "owner_id=" + id
					}).then((res) => {	
											
					}).catch((error )=> {
						console.log(error);
					});
				}
			});
		</script>
	</body>
</html>